<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/** 
<span class='line'>  2</span>  * (smt)2 simple mouse tracking - replay mode (smt-replay-2.0.0.js)
<span class='line'>  3</span>  * Copyleft (cc) 2006-2009 Luis Leiva
<span class='line'>  4</span>  * Release date: July 19th 2009
<span class='line'>  5</span>  * http://smt.speedzinemedia.com  
<span class='line'>  6</span>  * @class smt2-replay
<span class='line'>  7</span>  * @requires smt2-aux Auxiliary (smt)2 functions  
<span class='line'>  8</span>  * @version 2.0.0
<span class='line'>  9</span>  * @author Luis Leiva 
<span class='line'> 10</span>  * @license Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. 
<span class='line'> 11</span>  * @see smtAuxFn
<span class='line'> 12</span>  * @deprecated in favor of the new SWF visualization API 
<span class='line'> 13</span>  */</span><span class="WHIT">
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="WHIT">
<span class='line'> 15</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">smtReplay</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 16</span> 
<span class='line'> 17</span> </span><span class="WHIT">  </span><span class="COMM">/** 
<span class='line'> 18</span>    * (smt)2 default replaying options.
<span class='line'> 19</span>    * This Object should be overriden from the 'customize' section at the (smt)2 CMS.
<span class='line'> 20</span>    */</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">smtOpt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 23</span>      * Entry point color
<span class='line'> 24</span>      * @type string 
<span class='line'> 25</span>      */</span><span class="WHIT">  </span><span class="WHIT">
<span class='line'> 26</span> </span><span class="WHIT">    </span><span class="NAME">entryPt</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="STRN">"#9F6"</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 28</span>      * Exit point color
<span class='line'> 29</span>      * @type string     
<span class='line'> 30</span>      */</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">    </span><span class="NAME">exitPt</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="STRN">"#F66"</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 33</span>      * Registration points color
<span class='line'> 34</span>      * @type string      
<span class='line'> 35</span>      */</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">    </span><span class="NAME">regPt</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="STRN">"#F0F"</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 38</span>      * Lines color
<span class='line'> 39</span>      * @type string      
<span class='line'> 40</span>      */</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">    </span><span class="NAME">regLn</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="STRN">"#0CC"</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 43</span>      * Clicks color
<span class='line'> 44</span>      * @type string      
<span class='line'> 45</span>      */</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">    </span><span class="NAME">click</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="STRN">"#F00"</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 48</span>      * Drag and drop color
<span class='line'> 49</span>      * @type string      
<span class='line'> 50</span>      */</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">    </span><span class="NAME">dDrop</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="STRN">"#ABC"</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 53</span>      * User stops: time-depending circles color
<span class='line'> 54</span>      * @type string      
<span class='line'> 55</span>      */</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">    </span><span class="NAME">varCir</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="STRN">"#F99"</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 58</span>      * Centroid color
<span class='line'> 59</span>      * @type string      
<span class='line'> 60</span>      */</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">    </span><span class="NAME">cenPt</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="STRN">"#DDD"</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 63</span>      * Clusters color
<span class='line'> 64</span>      * @type string      
<span class='line'> 65</span>      */</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">    </span><span class="NAME">clust</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="STRN">"#00F"</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 68</span>      * Static (false) or dynamic mouse replay (true)
<span class='line'> 69</span>      * @type boolean      
<span class='line'> 70</span>      */</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">    </span><span class="NAME">realTime</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">     </span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 73</span>      * Draw background layer (true) or not (false)
<span class='line'> 74</span>      * @type boolean      
<span class='line'> 75</span>      */</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">    </span><span class="NAME">bgLayer</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 78</span>      * Background layer color
<span class='line'> 79</span>      * @type string
<span class='line'> 80</span>      */</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">    </span><span class="NAME">bgColor</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"#000"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'> 83</span>      * Show direction vector (useful if realTime: false)
<span class='line'> 84</span>      * @type boolean      
<span class='line'> 85</span>      */</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">    </span><span class="NAME">dirVect</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="KEYW">false</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">  </span><span class="COMM">/* do not edit below this line -------------------------------------------- */</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">  </span><span class="COMM">// get globals</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">smtData</span><span class="WHIT">     </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.smtData</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">jsGraphics</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.jsGraphics</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">aux</span><span class="WHIT">         </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.smtAuxFn</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">  </span><span class="COMM">// check globals</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">smtData</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="STRN">"user data is malformed or not set"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">jsGraphics</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="STRN">"jsGraphics library not found"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">       </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">aux</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">        </span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="STRN">"auxiliar (smt) functions not found"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>101</span> 
<span class='line'>102</span> </span><span class="WHIT">  </span><span class="COMM">// get user personalized settings</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">custom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.smtReplayOptions</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">custom</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">aux.overrideTrackingOptions</span><span class="PUNC">(</span><span class="NAME">smtOpt</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">custom</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">  </span><span class="COMM">// remove null distances to compute the mouse path centroid</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">xclean</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">yclean</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">  </span><span class="COMM">/* (smt) replay system definition ----------------------------------------- */</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">  </span><span class="COMM">/** 
<span class='line'>114</span>    * (smt)2 replaying object.
<span class='line'>115</span>    * This Object is private. Methods are cited but not documented.
<span class='line'>116</span>    */</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">smtRep</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">    </span><span class="NAME">i</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">                           </span><span class="COMM">// mouse tracking global counter var</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">    </span><span class="NAME">j</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">                           </span><span class="COMM">// registration points size global counter var</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">    </span><span class="NAME">jMax</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">                           </span><span class="COMM">// registration points size limit</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">    </span><span class="NAME">play</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">                        </span><span class="COMM">// mouse tracking identifier</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">    </span><span class="NAME">jg</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">                        </span><span class="COMM">// canvas area for drawing</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">    </span><span class="NAME">jgClust</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">                        </span><span class="COMM">// layer for clustering</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">    </span><span class="NAME">jgHelper</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">                       </span><span class="COMM">// layer for displaying text info</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">    </span><span class="NAME">viewport</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">width</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">      </span><span class="COMM">// data normalization</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">    </span><span class="NAME">discrepance</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">x</span><span class="PUNC">:</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">             </span><span class="COMM">// discrepance ratios</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">    </span><span class="NAME">paused</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">                       </span><span class="COMM">// pause the visualization</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>129</span>      * Create drawing canvas layer.
<span class='line'>130</span>      */</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">    </span><span class="NAME">createCanvas</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">layerName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">      </span><span class="COMM">// canvas layer for mouse trackig</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">jg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">"div"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">          </span><span class="NAME">jg.id</span><span class="WHIT">             </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">layerName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">          </span><span class="NAME">jg.style.position</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"absolute"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">          </span><span class="NAME">jg.style.top</span><span class="WHIT">      </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">          </span><span class="NAME">jg.style.left</span><span class="WHIT">     </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">          </span><span class="NAME">jg.style.width</span><span class="WHIT">    </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">100</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'%'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">          </span><span class="NAME">jg.style.height</span><span class="WHIT">   </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">100</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'%'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">          </span><span class="NAME">jg.style.zIndex</span><span class="WHIT">   </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.getNextHighestDepth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">      </span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">      </span><span class="COMM">// helper layer for text</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">jgHelp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">"div"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">          </span><span class="NAME">jgHelp.id</span><span class="WHIT">              </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">layerName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"Help"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">          </span><span class="NAME">jgHelp.style.zIndex</span><span class="WHIT">    </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jg.style.zIndex</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">          </span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">      </span><span class="COMM">// layer for clustering</span><span class="WHIT">
<span class='line'>149</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">opacity</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">40</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">jgClust</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">"div"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">          </span><span class="NAME">jgClust.id</span><span class="WHIT">              </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">layerName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"Clust"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">          </span><span class="NAME">jgClust.style.position</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"absolute"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">          </span><span class="NAME">jgClust.style.top</span><span class="WHIT">       </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">          </span><span class="NAME">jgClust.style.left</span><span class="WHIT">      </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">          </span><span class="NAME">jgClust.style.width</span><span class="WHIT">     </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">100</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'%'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">          </span><span class="NAME">jgClust.style.height</span><span class="WHIT">    </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">100</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'%'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">          </span><span class="NAME">jgClust.style.opacity</span><span class="WHIT">   </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opacity</span><span class="PUNC">/</span><span class="NUMB">100</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// for W3C browsers</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">          </span><span class="NAME">jgClust.style.filter</span><span class="WHIT">    </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"alpha(opacity="</span><span class="PUNC">+</span><span class="NAME">opacity</span><span class="PUNC">+</span><span class="STRN">")"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// only for IE</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">          </span><span class="NAME">jgClust.style.zIndex</span><span class="WHIT">    </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jg.style.zIndex</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">          </span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">body</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.getElementsByTagName</span><span class="PUNC">(</span><span class="STRN">"body"</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">          </span><span class="NAME">body.appendChild</span><span class="PUNC">(</span><span class="NAME">jg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">          </span><span class="NAME">body.appendChild</span><span class="PUNC">(</span><span class="NAME">jgHelp</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">          </span><span class="NAME">body.appendChild</span><span class="PUNC">(</span><span class="NAME">jgClust</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">          </span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">      </span><span class="COMM">// set the canvas areas for drawing both mouse tracking and clustering</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">jsGraphics</span><span class="PUNC">(</span><span class="NAME">jg.id</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jgHelper</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">jsGraphics</span><span class="PUNC">(</span><span class="NAME">jgHelp.id</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jgClust</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">jsGraphics</span><span class="PUNC">(</span><span class="NAME">jgClust.id</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>172</span>      * Create background layer.
<span class='line'>173</span>      */</span><span class="WHIT">
<span class='line'>174</span> </span><span class="WHIT">    </span><span class="NAME">setBgCanvas</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">layerName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>175</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">opacity</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">50</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// background layer opacity (%)</span><span class="WHIT">
<span class='line'>177</span> </span><span class="WHIT">          </span><span class="COMM">// set layer above the mouse tracking one</span><span class="WHIT">
<span class='line'>178</span> </span><span class="WHIT">          </span><span class="NAME">jg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.getElementById</span><span class="PUNC">(</span><span class="NAME">layerName</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">          </span><span class="NAME">doc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.getPageSize</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">          </span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">"div"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">          </span><span class="NAME">bg.id</span><span class="WHIT">                     </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">layerName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"Bg"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">          </span><span class="NAME">bg.style.position</span><span class="WHIT">         </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"absolute"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">          </span><span class="NAME">bg.style.top</span><span class="WHIT">              </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">          </span><span class="NAME">bg.style.left</span><span class="WHIT">             </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">          </span><span class="NAME">bg.style.width</span><span class="WHIT">            </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">doc.width</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'px'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">          </span><span class="NAME">bg.style.height</span><span class="WHIT">           </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">doc.height</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'px'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">          </span><span class="NAME">bg.style.overflow</span><span class="WHIT">         </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"hidden"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>189</span> </span><span class="WHIT">          </span><span class="NAME">bg.style.backgroundColor</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">smtOpt.bgColor</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT">          </span><span class="NAME">bg.style.opacity</span><span class="WHIT">          </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opacity</span><span class="PUNC">/</span><span class="NUMB">100</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// for W3C browsers</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">          </span><span class="NAME">bg.style.filter</span><span class="WHIT">           </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"alpha(opacity="</span><span class="PUNC">+</span><span class="NAME">opacity</span><span class="PUNC">+</span><span class="STRN">")"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// only for IE</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT">          </span><span class="NAME">bg.style.zIndex</span><span class="WHIT">           </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jg.style.zIndex</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT">      </span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">body</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.getElementsByTagName</span><span class="PUNC">(</span><span class="STRN">"body"</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">          </span><span class="NAME">body.appendChild</span><span class="PUNC">(</span><span class="NAME">bg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>198</span>      * Draw line.
<span class='line'>199</span>      */</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">    </span><span class="NAME">drawLine</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">ini</span><span class="PUNC">,</span><span class="NAME">end</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.setColor</span><span class="PUNC">(</span><span class="NAME">smtOpt.regLn</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.drawLine</span><span class="PUNC">(</span><span class="NAME">ini.x</span><span class="PUNC">,</span><span class="NAME">ini.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">end.x</span><span class="PUNC">,</span><span class="NAME">end.y</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.paint</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>207</span>      * Draw mouse click.
<span class='line'>208</span>      */</span><span class="WHIT">
<span class='line'>209</span> </span><span class="WHIT">    </span><span class="NAME">drawClick</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">isDragAndDrop</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">isDragAndDrop</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">        </span><span class="NAME">size</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">12</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">offset</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.setColor</span><span class="PUNC">(</span><span class="NAME">smtOpt.click</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.drawLine</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">size</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">size</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">offset</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">offset</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.drawLine</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">size</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">size</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">offset</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">offset</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.drawLine</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">size</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">size</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">offset</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">offset</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.drawLine</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">size</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">size</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">offset</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">offset</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">        </span><span class="NAME">size</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">6</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.setColor</span><span class="PUNC">(</span><span class="NAME">smtOpt.dDrop</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.drawRect</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">size</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">size</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">,</span><span class="NAME">size</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.paint</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>226</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>227</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>228</span>      * Draw direction arrow in a line.
<span class='line'>229</span>      */</span><span class="WHIT">
<span class='line'>230</span> </span><span class="WHIT">    </span><span class="NAME">drawDirectionArrow</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">ini</span><span class="PUNC">,</span><span class="NAME">end</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ini.x</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">end.x</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT">          </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ini.y</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">end.y</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">          </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">></span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">></span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.drawPolyline</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="NAME">end.x</span><span class="PUNC">-</span><span class="NAME">s</span><span class="PUNC">,</span><span class="NAME">end.x</span><span class="PUNC">,</span><span class="NAME">end.x</span><span class="PUNC">+</span><span class="NAME">s</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">end.y</span><span class="PUNC">+</span><span class="NAME">s</span><span class="PUNC">,</span><span class="NAME">end.y</span><span class="PUNC">,</span><span class="NAME">end.y</span><span class="PUNC">+</span><span class="NAME">s</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">&lt;</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">></span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.drawPolyline</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="NAME">end.x</span><span class="PUNC">-</span><span class="NAME">s</span><span class="PUNC">,</span><span class="NAME">end.x</span><span class="PUNC">,</span><span class="NAME">end.x</span><span class="PUNC">-</span><span class="NAME">s</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">end.y</span><span class="PUNC">-</span><span class="NAME">s</span><span class="PUNC">,</span><span class="NAME">end.y</span><span class="PUNC">,</span><span class="NAME">end.y</span><span class="PUNC">+</span><span class="NAME">s</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">&lt;</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">&lt;</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.drawPolyline</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="NAME">end.x</span><span class="PUNC">-</span><span class="NAME">s</span><span class="PUNC">,</span><span class="NAME">end.x</span><span class="PUNC">,</span><span class="NAME">end.x</span><span class="PUNC">+</span><span class="NAME">s</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">end.y</span><span class="PUNC">-</span><span class="NAME">s</span><span class="PUNC">,</span><span class="NAME">end.y</span><span class="PUNC">,</span><span class="NAME">end.y</span><span class="PUNC">-</span><span class="NAME">s</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">></span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">&lt;</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jg.drawPolyline</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="NAME">end.x</span><span class="PUNC">+</span><span class="NAME">s</span><span class="PUNC">,</span><span class="NAME">end.x</span><span class="PUNC">,</span><span class="NAME">end.x</span><span class="PUNC">+</span><span class="NAME">s</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">end.y</span><span class="PUNC">-</span><span class="NAME">s</span><span class="PUNC">,</span><span class="NAME">end.y</span><span class="PUNC">,</span><span class="NAME">end.y</span><span class="PUNC">+</span><span class="NAME">s</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.paint</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>247</span>      * Draw mouse cursor.
<span class='line'>248</span>      */</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT">    </span><span class="NAME">drawCursor</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">color</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>250</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>251</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.setColor</span><span class="PUNC">(</span><span class="NAME">color</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.fillPolygon</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">,</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="NAME">x</span><span class="PUNC">+</span><span class="NUMB">4</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">+</span><span class="NUMB">6</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">+</span><span class="NUMB">9</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">+</span><span class="NUMB">7</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">+</span><span class="NUMB">15</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT">                            </span><span class="PUNC">[</span><span class="NAME">y</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NUMB">15</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NUMB">15</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NUMB">23</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NUMB">23</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NUMB">15</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NUMB">15</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>254</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.paint</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>257</span>      * Draw registration point.
<span class='line'>258</span>      */</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT">    </span><span class="NAME">drawRegistrationPoint</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.setColor</span><span class="PUNC">(</span><span class="NAME">smtOpt.regPt</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.fillRect</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.paint</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>265</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>266</span>      * Draw time-depending circle.
<span class='line'>267</span>      */</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">    </span><span class="NAME">drawVariableCircle</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT">      </span><span class="COMM">// use multiplier to normalize all circles: 0 &lt; norm &lt; 1</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">norm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.roundTo</span><span class="PUNC">(</span><span class="NAME">size</span><span class="PUNC">/</span><span class="NAME">smtRep.jMax</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">size</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">norm</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">      </span><span class="COMM">// limit size to 1/2 of current window width (px)</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">size</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">smtData.wcurr</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">size</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="PUNC">(</span><span class="NAME">smtData.wcurr</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">norm</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">      </span><span class="COMM">// draw</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.setColor</span><span class="PUNC">(</span><span class="NAME">smtOpt.varCir</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.drawEllipse</span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.paint</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>281</span>      * Gives a visual clue when the user is not using the mouse.
<span class='line'>282</span>      */</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">    </span><span class="NAME">drawMouseStop</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">smtOpt.realTime</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT">      </span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fontSize</span><span class="WHIT">   </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT">          </span><span class="NAME">circleSize</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">50</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jgHelper.setColor</span><span class="PUNC">(</span><span class="NAME">smtOpt.varCir</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jgHelper.fillEllipse</span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">circleSize</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">circleSize</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">circleSize</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">circleSize</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jgHelper.setColor</span><span class="PUNC">(</span><span class="STRN">"black"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jgHelper.setFont</span><span class="PUNC">(</span><span class="STRN">"sans-serif"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontSize</span><span class="PUNC">+</span><span class="STRN">'px'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Font.BOLD</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">      </span><span class="COMM">// center the text in vertical </span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jgHelper.drawString</span><span class="PUNC">(</span><span class="STRN">"stopped..."</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">fontSize</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jgHelper.paint</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>298</span>      * Draw centroid as a star.
<span class='line'>299</span>      */</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT">    </span><span class="NAME">drawCentroid</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.setColor</span><span class="PUNC">(</span><span class="NAME">smtOpt.cenPt</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT">      </span><span class="COMM">// the centroid is computed discarding null distances</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">u</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="PUNC">(</span><span class="NAME">aux.array.sum</span><span class="PUNC">(</span><span class="NAME">xclean</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.x</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">xclean.length</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">          </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="PUNC">(</span><span class="NAME">aux.array.sum</span><span class="PUNC">(</span><span class="NAME">yclean</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.y</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">yclean.length</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT">          </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">20</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// centroid line length</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.setStroke</span><span class="PUNC">(</span><span class="NUMB">5</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT">    	</span><span class="NAME">smtRep.jg.drawLine</span><span class="PUNC">(</span><span class="NAME">u</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">u</span><span class="PUNC">+</span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">-</span><span class="NAME">l</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 1st quadrant</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT">    	</span><span class="NAME">smtRep.jg.drawLine</span><span class="PUNC">(</span><span class="NAME">u</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">u</span><span class="PUNC">-</span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">-</span><span class="NAME">l</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 2nd quadrant</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">    	</span><span class="NAME">smtRep.jg.drawLine</span><span class="PUNC">(</span><span class="NAME">u</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">u</span><span class="PUNC">-</span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">+</span><span class="NAME">l</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 3rd quadrant</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT">    	</span><span class="NAME">smtRep.jg.drawLine</span><span class="PUNC">(</span><span class="NAME">u</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">u</span><span class="PUNC">+</span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">+</span><span class="NAME">l</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 4th quadrant</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">    	</span><span class="NAME">smtRep.jg.setStroke</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// reset strokes</span><span class="WHIT">
<span class='line'>313</span> </span><span class="WHIT">    	</span><span class="NAME">smtRep.jg.paint</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>315</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>316</span>      * Draw cluster as a circle.
<span class='line'>317</span>      */</span><span class="WHIT">
<span class='line'>318</span> </span><span class="WHIT">    </span><span class="NAME">drawClusters</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>319</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>320</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jgClust.setColor</span><span class="PUNC">(</span><span class="NAME">smtOpt.clust</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>321</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>322</span> </span><span class="WHIT">      </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">clusters</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">smtData.clustsize.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">clusters</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>323</span> </span><span class="WHIT">        </span><span class="NAME">size</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">smtData.clustsize</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>324</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jgClust.fillEllipse</span><span class="PUNC">(</span><span class="NAME">smtData.xclusters</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.x</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtData.yclusters</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.y</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>325</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>326</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jgClust.paint</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>327</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>328</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>329</span>      * Get euclidean distance from point a to point b.
<span class='line'>330</span>      */</span><span class="WHIT">
<span class='line'>331</span> </span><span class="WHIT">    </span><span class="NAME">distance</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">,</span><span class="NAME">b</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>332</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>333</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Math.sqrt</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">Math.pow</span><span class="PUNC">(</span><span class="NAME">a.x</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">b.x</span><span class="PUNC">,</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">Math.pow</span><span class="PUNC">(</span><span class="NAME">a.y</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">b.y</span><span class="PUNC">,</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>336</span>      * Auto scrolls the browser window.
<span class='line'>337</span>      */</span><span class="WHIT">
<span class='line'>338</span> </span><span class="WHIT">    </span><span class="NAME">checkAutoScrolling</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="NAME">y</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>340</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">smtOpt.realTime</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>341</span> </span><span class="WHIT">      </span><span class="COMM">// center current mouse coords on the viewport</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT">      </span><span class="NAME">aux.doScroll</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="NAME">xpos</span><span class="PUNC">:</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ypos</span><span class="PUNC">:</span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">width</span><span class="PUNC">:</span><span class="NAME">smtRep.viewport.width</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">height</span><span class="PUNC">:</span><span class="NAME">smtRep.viewport.height</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>343</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>344</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>345</span>      * (smt)2 realtime drawing algorithm.
<span class='line'>346</span>      */</span><span class="WHIT">
<span class='line'>347</span> </span><span class="WHIT">    </span><span class="NAME">playMouse</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>348</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>349</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtRep.paused</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>350</span> 
<span class='line'>351</span> </span><span class="WHIT">      </span><span class="COMM">// mouse coords normalization</span><span class="WHIT">
<span class='line'>352</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">iniMouse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>353</span> </span><span class="WHIT">                        </span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">smtData.xcoords</span><span class="PUNC">[</span><span class="NAME">smtRep.i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.x</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>354</span> </span><span class="WHIT">                        </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">smtData.ycoords</span><span class="PUNC">[</span><span class="NAME">smtRep.i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.y</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>355</span> </span><span class="WHIT">                     </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>356</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">endMouse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>357</span> </span><span class="WHIT">                        </span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">smtData.xcoords</span><span class="PUNC">[</span><span class="NAME">smtRep.i</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.x</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>358</span> </span><span class="WHIT">                        </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">smtData.ycoords</span><span class="PUNC">[</span><span class="NAME">smtRep.i</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.y</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>359</span> </span><span class="WHIT">                     </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>360</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">iniClick</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>361</span> </span><span class="WHIT">                        </span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">smtData.xclicks</span><span class="PUNC">[</span><span class="NAME">smtRep.i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>362</span> </span><span class="WHIT">                        </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">smtData.yclicks</span><span class="PUNC">[</span><span class="NAME">smtRep.i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.y</span><span class="WHIT">
<span class='line'>363</span> </span><span class="WHIT">                     </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>364</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">endClick</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>365</span> </span><span class="WHIT">                        </span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">smtData.xclicks</span><span class="PUNC">[</span><span class="NAME">smtRep.i</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>366</span> </span><span class="WHIT">                        </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">smtData.yclicks</span><span class="PUNC">[</span><span class="NAME">smtRep.i</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.y</span><span class="WHIT">
<span class='line'>367</span> </span><span class="WHIT">                     </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>368</span> </span><span class="WHIT">      </span><span class="WHIT">
<span class='line'>369</span> </span><span class="WHIT">      </span><span class="COMM">// draw entry point</span><span class="WHIT">
<span class='line'>370</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtRep.i</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>371</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.drawCursor</span><span class="PUNC">(</span><span class="NAME">iniMouse.x</span><span class="PUNC">,</span><span class="NAME">iniMouse.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtOpt.entryPt</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>372</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>373</span> </span><span class="WHIT">      </span><span class="WHIT">
<span class='line'>374</span> </span><span class="WHIT">      </span><span class="COMM">// main loop to draw mouse trail</span><span class="WHIT">
<span class='line'>375</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtRep.i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">smtData.xcoords.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">      </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>377</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">mouseDistance</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">smtRep.distance</span><span class="PUNC">(</span><span class="NAME">iniMouse</span><span class="PUNC">,</span><span class="NAME">endMouse</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>378</span> </span><span class="WHIT">        </span><span class="COMM">// draw registration points</span><span class="WHIT">
<span class='line'>379</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">mouseDistance</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT">          </span><span class="COMM">// there is mouse movement</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">smtOpt.dirVect</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">            </span><span class="COMM">// show static squares</span><span class="WHIT">
<span class='line'>383</span> </span><span class="WHIT">            </span><span class="NAME">smtRep.drawRegistrationPoint</span><span class="PUNC">(</span><span class="NAME">iniMouse.x</span><span class="PUNC">,</span><span class="NAME">iniMouse.y</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>384</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>385</span> </span><span class="WHIT">            </span><span class="COMM">// show direction pseudo-arrows</span><span class="WHIT">
<span class='line'>386</span> </span><span class="WHIT">            </span><span class="NAME">smtRep.drawDirectionArrow</span><span class="PUNC">(</span><span class="NAME">iniMouse</span><span class="PUNC">,</span><span class="NAME">endMouse</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>387</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>388</span> </span><span class="WHIT">          </span><span class="COMM">// variable circles</span><span class="WHIT">
<span class='line'>389</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtRep.j</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>390</span> </span><span class="WHIT">            </span><span class="NAME">smtRep.drawVariableCircle</span><span class="PUNC">(</span><span class="NAME">iniMouse.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iniMouse.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtRep.j</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT">            </span><span class="NAME">smtRep.jgHelper.clear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">          </span><span class="COMM">// reset variable circles size</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT">          </span><span class="NAME">smtRep.j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>396</span> </span><span class="WHIT">          </span><span class="COMM">// mouse stop: store variable size (circles)</span><span class="WHIT">
<span class='line'>397</span> </span><span class="WHIT">          </span><span class="PUNC">++</span><span class="NAME">smtRep.j</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>398</span> </span><span class="WHIT">          </span><span class="NAME">smtRep.drawMouseStop</span><span class="PUNC">(</span><span class="NAME">iniMouse.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iniMouse.y</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>399</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>400</span> </span><span class="WHIT">        </span><span class="COMM">// draw lines</span><span class="WHIT">
<span class='line'>401</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.drawLine</span><span class="PUNC">(</span><span class="NAME">iniMouse</span><span class="PUNC">,</span><span class="NAME">endMouse</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>402</span> </span><span class="WHIT">        </span><span class="COMM">// draw clicks</span><span class="WHIT">
<span class='line'>403</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">iniClick.x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>404</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">clickDistance</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">smtRep.distance</span><span class="PUNC">(</span><span class="NAME">iniClick</span><span class="PUNC">,</span><span class="NAME">endClick</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>405</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">clickDistance</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>406</span> </span><span class="WHIT">            </span><span class="COMM">// is a single click</span><span class="WHIT">
<span class='line'>407</span> </span><span class="WHIT">            </span><span class="NAME">smtRep.drawClick</span><span class="PUNC">(</span><span class="NAME">endClick.x</span><span class="PUNC">,</span><span class="NAME">endClick.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>408</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">endClick.x</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>409</span> </span><span class="WHIT">            </span><span class="COMM">// is drag and drop</span><span class="WHIT">
<span class='line'>410</span> </span><span class="WHIT">            </span><span class="NAME">smtRep.drawClick</span><span class="PUNC">(</span><span class="NAME">iniClick.x</span><span class="PUNC">,</span><span class="NAME">iniClick.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>411</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>412</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>413</span> </span><span class="WHIT">        </span><span class="COMM">// update mouse coordinates</span><span class="WHIT">
<span class='line'>414</span> </span><span class="WHIT">        </span><span class="PUNC">++</span><span class="NAME">smtRep.i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>415</span> </span><span class="WHIT">        </span><span class="COMM">// check auto scrolling</span><span class="WHIT">
<span class='line'>416</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.checkAutoScrolling</span><span class="PUNC">(</span><span class="NAME">endMouse.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">endMouse.y</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>417</span> </span><span class="WHIT">    	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>418</span> </span><span class="WHIT">      </span><span class="WHIT">
<span class='line'>419</span> </span><span class="WHIT">      </span><span class="COMM">// draw exit point</span><span class="WHIT">
<span class='line'>420</span> </span><span class="WHIT">      </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>421</span> </span><span class="WHIT">    	  </span><span class="COMM">// rewind count 1 step to access the last mouse coordinate</span><span class="WHIT">
<span class='line'>422</span> </span><span class="WHIT">    	  </span><span class="PUNC">--</span><span class="NAME">smtRep.i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>423</span> </span><span class="WHIT">    	  </span><span class="NAME">iniMouse.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">smtData.xcoords</span><span class="PUNC">[</span><span class="NAME">smtRep.i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>424</span> </span><span class="WHIT">        </span><span class="NAME">iniMouse.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">smtData.ycoords</span><span class="PUNC">[</span><span class="NAME">smtRep.i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">smtRep.discrepance.y</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>425</span> </span><span class="WHIT">        </span><span class="COMM">// draw exit point</span><span class="WHIT">
<span class='line'>426</span> </span><span class="WHIT">    	  </span><span class="NAME">smtRep.drawCursor</span><span class="PUNC">(</span><span class="NAME">iniMouse.x</span><span class="PUNC">,</span><span class="NAME">iniMouse.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">smtOpt.exitPt</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>427</span> </span><span class="WHIT">    	  </span><span class="COMM">// draw clusters</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT">    	  </span><span class="NAME">smtRep.drawClusters</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT">        </span><span class="COMM">// draw centroid (average mouse position) </span><span class="WHIT">
<span class='line'>430</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.drawCentroid</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>431</span> </span><span class="WHIT">        </span><span class="COMM">// clear mouse tracking</span><span class="WHIT">
<span class='line'>432</span> </span><span class="WHIT">        </span><span class="NAME">clearInterval</span><span class="PUNC">(</span><span class="NAME">smtRep.play</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>433</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.play</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>434</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.jgHelper.clear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>435</span> </span><span class="WHIT">        </span><span class="COMM">// load next trail</span><span class="WHIT">
<span class='line'>436</span> </span><span class="WHIT">        </span><span class="NAME">aux.loadNextMouseTrail</span><span class="PUNC">(</span><span class="NAME">smtData</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>437</span> </span><span class="WHIT">    	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>438</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>439</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>440</span>      * Replay method: static or dynamic.
<span class='line'>441</span>      */</span><span class="WHIT">
<span class='line'>442</span> </span><span class="WHIT">    </span><span class="NAME">replay</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">realtime</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>443</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>444</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">realtime</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>445</span> </span><span class="WHIT">        </span><span class="COMM">// fps are stored in smtData object, so we can use that value here</span><span class="WHIT">
<span class='line'>446</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">interval</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="PUNC">(</span><span class="NUMB">1000</span><span class="PUNC">/</span><span class="NAME">smtData.fps</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>447</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.play</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">setInterval</span><span class="PUNC">(</span><span class="NAME">smtRep.playMouse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">interval</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>448</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>449</span> </span><span class="WHIT">        </span><span class="COMM">// static mouse tracking visualization </span><span class="WHIT">
<span class='line'>450</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">total</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">smtData.xcoords.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NAME">total</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>451</span> </span><span class="WHIT">          </span><span class="NAME">smtRep.playMouse</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>452</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>453</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>454</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>455</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>456</span>      * Reload method: mouse tracking layers are redrawn.
<span class='line'>457</span>      */</span><span class="WHIT">
<span class='line'>458</span> </span><span class="WHIT">    </span><span class="NAME">reset</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>459</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>460</span> </span><span class="WHIT">      </span><span class="NAME">clearInterval</span><span class="PUNC">(</span><span class="NAME">smtRep.play</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>461</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.paused</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>462</span> </span><span class="WHIT">      </span><span class="COMM">// reset counters</span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>464</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">    </span><span class="WHIT">
<span class='line'>465</span> </span><span class="WHIT">      </span><span class="COMM">// clear canvas  </span><span class="WHIT">
<span class='line'>466</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jg.clear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>467</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jgClust.clear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>468</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>469</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>470</span>      * User can pause the mouse replay by pressing the SPACE key, 
<span class='line'>471</span>      * or toggle replay mode by pressing the ESC key.
<span class='line'>472</span>      */</span><span class="WHIT">
<span class='line'>473</span> </span><span class="WHIT">    </span><span class="NAME">helpKeys</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>474</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>475</span> </span><span class="WHIT">      </span><span class="COMM">// use helpKeys only in realtime replaying</span><span class="WHIT">
<span class='line'>476</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">smtOpt.realTime</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>477</span> </span><span class="WHIT">      </span><span class="WHIT">
<span class='line'>478</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.event</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>479</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">code</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e.keyCode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">e.which</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>480</span> </span><span class="WHIT">      </span><span class="COMM">// on press ESC key finish drawing</span><span class="WHIT">
<span class='line'>481</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">code</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">27</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>482</span> </span><span class="WHIT">        </span><span class="COMM">// clear main loop</span><span class="WHIT">
<span class='line'>483</span> </span><span class="WHIT">        </span><span class="NAME">clearInterval</span><span class="PUNC">(</span><span class="NAME">smtRep.play</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>484</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.paused</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>485</span> </span><span class="WHIT">        </span><span class="COMM">// set this flag</span><span class="WHIT">
<span class='line'>486</span> </span><span class="WHIT">        </span><span class="NAME">smtOpt.realTime</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>487</span> </span><span class="WHIT">        </span><span class="COMM">// end drawing from the current position</span><span class="WHIT">
<span class='line'>488</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">smtRep.i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">total</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">smtData.xcoords.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NAME">total</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>489</span> </span><span class="WHIT">          </span><span class="NAME">smtRep.playMouse</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>490</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>491</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">code</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>492</span> </span><span class="WHIT">        </span><span class="COMM">// on press space bar toggle drawing</span><span class="WHIT">
<span class='line'>493</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.paused</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">smtRep.paused</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>494</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>495</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>496</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>497</span>      * System initialization.
<span class='line'>498</span>      */</span><span class="WHIT">
<span class='line'>499</span> </span><span class="WHIT">    </span><span class="NAME">init</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>500</span> </span><span class="WHIT">    </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>501</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">vp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.getWindowSize</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.viewport.width</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">vp.width</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>503</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.viewport.height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">vp.height</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>504</span> </span><span class="WHIT">      </span><span class="WHIT">
<span class='line'>505</span> </span><span class="WHIT">      </span><span class="COMM">// compute the discrepance ratio</span><span class="WHIT">
<span class='line'>506</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtData.wprev</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">smtData.hprev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>507</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.discrepance.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.roundTo</span><span class="PUNC">(</span><span class="NAME">smtData.wcurr</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">smtData.wprev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>508</span> </span><span class="WHIT">        </span><span class="NAME">smtRep.discrepance.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.roundTo</span><span class="PUNC">(</span><span class="NAME">smtData.hcurr</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">smtData.hprev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">  </span><span class="WHIT">
<span class='line'>509</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>510</span> </span><span class="WHIT">      </span><span class="COMM">//aux.log(smtRep.discrepance.x+" x "+smtRep.discrepance.y+" | "+smtRep.viewport.width+" x "+smtRep.viewport.height);</span><span class="WHIT">
<span class='line'>511</span> </span><span class="WHIT">          </span><span class="WHIT">
<span class='line'>512</span> </span><span class="WHIT">      </span><span class="COMM">// precalculate the user stops: useful for time-depending circles and path centroid</span><span class="WHIT">
<span class='line'>513</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">stops</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">      </span><span class="WHIT">
<span class='line'>514</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">size</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>515</span> </span><span class="WHIT">      </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">smtData.xcoords.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>516</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtData.xcoords</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">smtData.xcoords</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">smtData.ycoords</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">smtData.ycoords</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>517</span> </span><span class="WHIT">          </span><span class="PUNC">++</span><span class="NAME">size</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>518</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT">          </span><span class="COMM">// store all user stops (time) for drawing variable circles later</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">size</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">stops.push</span><span class="PUNC">(</span><span class="NAME">size</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>521</span> </span><span class="WHIT">          </span><span class="NAME">size</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>522</span> </span><span class="WHIT">          </span><span class="COMM">// store clean mouse coordinates</span><span class="WHIT">
<span class='line'>523</span> </span><span class="WHIT">          </span><span class="NAME">xclean.push</span><span class="PUNC">(</span><span class="NAME">smtData.xcoords</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>524</span> </span><span class="WHIT">          </span><span class="NAME">yclean.push</span><span class="PUNC">(</span><span class="NAME">smtData.ycoords</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>525</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>526</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>527</span> </span><span class="WHIT">      </span><span class="COMM">// set max size for variable circles</span><span class="WHIT">
<span class='line'>528</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.jMax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aux.array.max</span><span class="PUNC">(</span><span class="NAME">stops</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">       </span><span class="WHIT">
<span class='line'>529</span> </span><span class="WHIT">      </span><span class="COMM">// common suffix for tracking canvas and background layers</span><span class="WHIT">
<span class='line'>530</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">smtName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"smtCanvas"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>531</span> </span><span class="WHIT">      </span><span class="COMM">// set the canvas layer</span><span class="WHIT">
<span class='line'>532</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.createCanvas</span><span class="PUNC">(</span><span class="NAME">smtName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>533</span> </span><span class="WHIT">      </span><span class="COMM">// draw the background layer</span><span class="WHIT">
<span class='line'>534</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">smtOpt.bgLayer</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">smtRep.setBgCanvas</span><span class="PUNC">(</span><span class="NAME">smtName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>535</span> </span><span class="WHIT">      </span><span class="COMM">// allow mouse replay over Flash animations</span><span class="WHIT">
<span class='line'>536</span> </span><span class="WHIT">      </span><span class="NAME">aux.allowTrackingOnFlashObjects</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>537</span> </span><span class="WHIT">      </span><span class="COMM">// init</span><span class="WHIT">
<span class='line'>538</span> </span><span class="WHIT">      </span><span class="NAME">smtRep.replay</span><span class="PUNC">(</span><span class="NAME">smtOpt.realTime</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>539</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>540</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>541</span> </span><span class="WHIT">  </span><span class="WHIT">
<span class='line'>542</span> </span><span class="WHIT">  </span><span class="COMM">/* (smt)2 replay initialization ------------------------------------------- */</span><span class="WHIT">
<span class='line'>543</span> </span><span class="WHIT">  </span><span class="NAME">aux.addEvent</span><span class="PUNC">(</span><span class="NAME">document</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"keyup"</span><span class="PUNC">,</span><span class="WHIT">  </span><span class="NAME">smtRep.helpKeys</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>544</span> </span><span class="WHIT">  </span><span class="COMM">//aux.addEvent(window, "resize", smtRep.reset);</span><span class="WHIT">
<span class='line'>545</span> </span><span class="WHIT">  </span><span class="NAME">aux.onDOMload</span><span class="PUNC">(</span><span class="NAME">smtRep.init</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>546</span> 
<span class='line'>547</span> </span><span class="PUNC">}</span></pre></body></html>